#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int arr1[30],arr2[30];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (int j = 0; j < m; j++)
	{
		scanf("%d", &arr2[j]);
	}
	int i = 0, j = 0,arr3[30],k=0;
	while (i<n&&j<m)
	{
		if (arr1[i] > arr2[j])
		{
			arr3[k] = arr2[j];
			j++;
			k++;
		}
		else {
			arr3[k] = arr1[i];
			i++;
			k++;
		}
	}
	if (i == n)
	{
		for (; j < m; j++)
		{
			arr3[k] = arr2[j];
			k++;
		}
	}
	else {
		for (; i < n; i++)
		{
			arr3[k] = arr1[i];
			k++;
		}
	}
	for (int k = 0; k < n + m; k++)
	{
		printf("%d ", arr3[k]);
	}
	return 0;
}